using System;
using System.Collections.Generic;
using System.Text;

namespace BussinessLogicTecnoPez
{
    /// <summary>
    /// Atributo que se debe usar en las clases para indicar la tabla que se corresponde
    /// en la base de datos.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
    public class DBTable : Attribute
    {
        private string Name;

        //Constructor
        public DBTable(string nam)
        {
            Name = nam;
        }

        public override string ToString()
        {
            return Name;
        }
    }

    /// <summary>
    /// Atributo que se debe usar en las Propertys para indicar con que campo
    /// de una tabla de la base de datos se corresponde.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class DBField : Attribute
    {
        private string name;
        private bool isKey;
        private bool isAutonumeric;
        private bool isForeingKey;
        private string foreingTableField;

        public string Name
        {
            get { return name; }
            //set { nombre = value; }
        }
        public bool IsKey
        {
            get { return isKey; }
            //set { isKey = value; }
        }
        public bool IsAutonumeric
        {
            get { return isAutonumeric; }
            //set { isAutonumeric = value; }
        }
        public bool IsForeingKey
        {
            get { return isForeingKey; }
            //set { isClass = values; }
        }
        public string ForeingTable
        {
            get { return foreingTableField; }
            set { foreingTableField = ForeingTable; }
        }

        //Constructor
        public DBField(string name, bool isKey, bool isAutonumeric)
        {
            this.name = name;
            this.isKey = isKey;
            this.isAutonumeric = isAutonumeric;
            this.isForeingKey = false;
        }

        /// <summary>
        /// En un ForeingKey, el name es el nombre del campo en la tabla y 
        /// el ForeingKay es el nombre del campo relacionado en la tabla
        /// foranea.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="isKey"></param>
        /// <param name="isAutonumeric"></param>
        /// <param name="isForeingKey"></param>
        public DBField(string name, bool isKey, bool isAutonumeric, bool isForeingKey, string foreingName)
        {
            this.name = name;
            this.isKey = isKey;
            this.isAutonumeric = isAutonumeric;
            this.isForeingKey = isForeingKey;
            this.foreingTableField = foreingName;
        }

        public override string ToString()
        {
            return name;
        }

    }
    /// <summary>
    /// Atributo que se utiliza para indicar un campo de tipo detalle.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class DBFieldDetail : Attribute
    {
        private string name;
        private Type itemType;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        public Type ItemType
        {
            get { return itemType; }
            set { itemType = value; }
        }
        /// <summary>
        /// DEbe de especificar el nombre de la columna que los une (foreing key en la tabal detalle)
        /// y el tipo del ITEM!!!!!!!!!!!!!!!!!!!!! no de la clase que hace de puente.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="itemType"></param>
        public DBFieldDetail(string name, Type itemType)
        {
            Name = name;
            ItemType = itemType;
        }
        public override string ToString()
        {
            return Name;
        }
    }

    /// <summary>
    /// Atributo para marcar friendlys names para utilizar en interfaz.
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class FriendlyName : Attribute
    {
        public enum FilterType
        {
            Integer = 1,
            String = 2
        }

        public FriendlyName(string fName, bool showInCompact)
        {
            this.myFriendlyName = fName;
            this.ShowInCompactPresentation = showInCompact;
        }
        public FriendlyName(string fName, bool showInCompact, bool showFilter, FilterType filterType)
        {
            this.myFriendlyName = fName;
            this.ShowInCompactPresentation = showInCompact;
            this.ShowFilter = showFilter;
            this.Type = filterType;
        }
        private string friendlyName;
        /// <summary>
        /// Nombre amistoso a mostrar en interfaz
        /// </summary>
        public string myFriendlyName
        {
            get { return friendlyName; }
            set { friendlyName = value; }
        }
        private bool showInCompactPresentation;
        /// <summary>
        /// Determina si el nombre amistoso debe o no ser mostrado si se habilitan
        /// vistas compactas.
        /// </summary>
        public bool ShowInCompactPresentation
        {
            get { return showInCompactPresentation; }
            set { showInCompactPresentation = value; }
        }
        private bool showFilter;
        /// <summary>
        /// Indica si se puede filtrar por este campo
        /// </summary>
        public bool ShowFilter
        {
            get { return showFilter; }
            set { showFilter = value; }
        }
        private FilterType filterType;
        /// <summary>
        /// Indica el tipo de dato del campo a filtrar
        /// </summary>
        public FilterType Type
        {
            get { return filterType; }
            set { filterType = value; }
        }
    }
}
